
package pri.syl.xiaowu.websocket.netty.server.thread.execution;

import  pri.syl.xiaowu.websocket.core.exception.WebsocketException;
import pri.syl.xiaowu.websocket.core.template.WebsocketChannelTemplate;
import pri.syl.xiaowu.websocket.core.template.WebsocketRouteTemplate;
import pri.syl.xiaowu.websocket.netty.server.handler.core.strategy.MessageEventStrategy;
import pri.syl.xiaowu.websocket.netty.server.thread.AbstractWebsocketServerBusinessThread;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;

/**
 * @Author YunLong
 * @Date 2021/7/18 19:21
 * @Description WebSocketMessage执行器
 **/
public class WebsocketServerBusinessThreadExecution extends AbstractWebsocketServerBusinessThread {
    public WebsocketServerBusinessThreadExecution(WebsocketRouteTemplate websocketRouteTemplate, WebsocketChannelTemplate websocketChannelTemplate, WebSocketFrame webSocketFrame) {
        super(websocketRouteTemplate, websocketChannelTemplate, webSocketFrame);
    }

    @Override
    protected void businessExecution(WebsocketRouteTemplate websocketRouteTemplate, WebsocketChannelTemplate websocketChannelTemplate, WebSocketFrame webSocketFrame) {
        try {
            MessageEventStrategy.messageEvent(websocketRouteTemplate, websocketChannelTemplate, webSocketFrame);
        } catch (Exception e) {
            websocketRouteTemplate.errorEvent(websocketChannelTemplate, new WebsocketException(e));
        }
    }
}
